package com.fanshuai.springcloud.controller;

import com.fanshuai.springcloud.domain.Book;
import com.fanshuai.springcloud.domain.User;
import com.fanshuai.springcloud.feign.BookServiceFeign2;
import com.fanshuai.springcloud.feign.UserServiceFeign2;
import com.fanshuai.springcloud.web.response.CallResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/hystrix")
public class HystrixController {
    @Resource
    private BookServiceFeign2 bookServiceFeign2;
    @Resource
    private UserServiceFeign2 userServiceFeign2;


    @GetMapping("/books")
    public CallResult<List<Book>> books() {
        return bookServiceFeign2.list();
    }

    @GetMapping("/users")
    public CallResult<List<User>> users() {
        return userServiceFeign2.list();
    }
}
